﻿Imports System.Xml

Namespace HybrisItems.Model

    ''' <summary>
    ''' Specifies a specific ComposedType.
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class ItemTypeModel
        Inherits TypeModel

        Public Sub New()

        End Sub

        Public Sub New(Node As XmlNode)

            Fill(Node)

        End Sub

        ''' <summary>
        ''' Is this Model object correctly wired to its related Model objects
        ''' </summary>
        ''' <remarks></remarks>
        Public Overrides ReadOnly Property IsWired As Boolean
            Get
                '   Me.Extends.IsWired
                Return Me.Extends.IsWired() AndAlso Me.Attributes.IsWired()
            End Get
        End Property

        Public Sub Fill(Node As XmlNode)

            Me.Description = ConfigParser.GetAttribute(Node, "description")

            'ToDo: Unset Config Properties
            ' Me.Deployment
            ' Me.CustomProperties
            ' Me.Attributes()
            ' Me.Indexes
            ' Me.Model

            Me.Code = New CodeModel(Node)

            'ToDo: Unset Config Properties
            ' Me.Extends
            ' Me.JaloClass
            ' Me.Singleton
            ' Me.JaloOnly
            ' Me.AutoCreate
            ' Me.Generate
            ' Me.Abstract
            ' Me.MetaType

        End Sub

        Public Overrides Sub Wire(Model As EntireHybrisSystemModel)

            'ToDo: Wire Method
            Me.Extends.Wire(Model)
            Me.Attributes.Wire(Model)

        End Sub

#Region "Config Properties"

        ''' <summary>
        ''' Provides possibility to add meaningfull description phrase for a generated model class.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Description As String

        ''' <summary>
        ''' A deployment defines how a (generic) item or relation is mapped onto the database.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Deployment As DeploymentModel

        ''' <summary>
        ''' Defines a list of custom properties for this type.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CustomProperties As CustomPropertiesModel

        ''' <summary>
        ''' Defines the list of item attributes.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Attributes As AttributesModel

        ''' <summary>
        ''' Defines the database indexes for this type.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Indexes As IndexesModel

        ''' <summary>
        ''' Allows to configure model generation for this item used at servicelayer.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Model As ItemModelModel

        ''' <summary>
        ''' The unique code of this type.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Code As CodeModel

        ''' <summary>
        ''' Defines the class, which will be extended. Default is 'GenericItem'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Extends As ClassModel

        ''' <summary>
        ''' Specifies the name of the associated jalo class. Default is [extension-root-package].jalo.[type-code] which will be generated if not existent.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property JaloClass As ClassModel

        ' ''' <summary>
        ' ''' Deprecated, please use separate deployment sub tag. 
        ' ''' All instances of this type will be stored in a separated database table. 
        ' ''' The value of this attribute represents a reference to the specified deployment in the corresponding 'advanced-deployment.xml'.
        ' ''' Default is empty.
        ' ''' </summary>
        ' ''' <value></value>
        ' ''' <returns></returns>
        ' ''' <remarks></remarks>
        '<Obsolete()> _
        'Public Property Deployment As DeploymentRefModel

        ''' <summary>
        ''' If 'true', type gets marked as singleton which will be evaluated by some modules like hmc or impex, 
        ''' with that allowing only one instance per system. Default is 'false'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Singleton As Boolean = False

        ''' <summary>
        ''' DEPRECATED. Use 'implements JaloOnlyItem' in your bean. 
        ''' If 'true', the item will only exists in the jalo layer and isn't backed by an entity bean. Default is 'false'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <Obsolete()> _
        Public Property JaloOnly As Boolean

        ''' <summary>
        ''' If 'true', the item will be created during initialization. Default is 'true'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property AutoCreate As Boolean = True

        ''' <summary>
        ''' If 'true', the item will be created during initialization. Default is 'true'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Generate As Boolean = True

        ''' <summary>
        ''' Marks type and jalo class as abstract. If 'true', the type can not be instantiated. Default is 'false'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>e
        Public Property Abstract As Boolean = False

        ''' <summary>
        ''' The (meta)type which describes the assigned type. Must be a type extensing ComposedType. Default is 'ComposedType'.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property MetaType As String = "ComposedType"

#End Region

    End Class

End Namespace